

        var toTop = href = null;
        var reference = 0;
        var judge = null;
        var picAnimateDelay = null;
        var step = 50;
        /*href = setInterval(function(){
            console.log(window.location.href);
        },10)*/
        function backToTop(){
            
            //取触发定时器前的初始滚动高度为参考值
            reference = Math.ceil(document.documentElement.scrollTop || document.body.scrollTop) + 1;
            console.log(reference);
            toTop = setInterval(function(){
                
                var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
                //参考值减去实际值,实际值为递增,相减结果则递减,after则递增,滚动速度从慢到快
                var after = scrollTop - Math.ceil((reference - scrollTop) / step);
                
                document.documentElement.scrollTop = document.body.scrollTop = after;
                if(after <= 0){
                    document.documentElement.scrollTop = document.body.scrollTop = 0;
                    clearInterval(toTop);
                    toTop = null;
                }
            },10)
        }
        function updateChoose(txt,ind){
            //被点击按钮索引    
            var index = ind;
            //可点击按钮数
            var btn = $('.choosePage>p').length;
            //当前被点击的页数
            var inner = txt;
            //总页数
            var pages = $('.choosePage>p:eq(' + [btn - 1] + ')').text();
            //需更新数据页数
            var num = 6;
            //省略号所在位置为第3或倒数第3
            var ellipsis = 2;
            
            judge = setInterval(function(){
                
                if(toTop) return false;
                if(pages <= 9){
                    
                }else{
                    if(inner >= pages - 5 && $('.choosePage .ellipsis')[0].ind > btn / 2){
                        console.log(1);
                        $('.choosePage>p').removeClass('current');
                        $('.choosePage>p').removeClass('ellipsis');
                        $('.choosePage>p:eq(' + ellipsis + ')').addClass('ellipsis');
                        var t = $('.choosePage>p:eq(' + ellipsis + ')').text();
                        var h = $('.choosePage>p:eq(' + ellipsis + ')').html().replace(t,'');

                        $('.choosePage>p:eq(' + ellipsis + ')').html('...' + h);
                        
                        for(var n = 0;n < num;n++){
                            var text = $('.choosePage>p')[btn - 1 - n].innerText;
                            var html = $('.choosePage>p')[btn - 1 - n].innerHTML.replace(text,'');
                            $('.choosePage>p')[btn - 1 - n].innerHTML = pages - n + html;
                            
                        }
                        for(var e = 0;e < ellipsis;e++){
                            var text = $('.choosePage>p')[e].innerText;
                            var html = $('.choosePage>p')[e].innerHTML.replace(text,'');
                            $('.choosePage>p')[e].innerHTML = e + 1 + html;
                        }
                        console.log(inner);
                        for(var c = 0;c < btn;c++){
                            if($('.choosePage>p')[c].innerText == inner){
                                $('.choosePage>p:eq(' + c + ')').addClass('current');
                            }
                        }
                    }
                    else if(inner <= pages - 5 && $('.choosePage .ellipsis')[0].ind < btn / 2){
                        console.log(3);
                        $('.choosePage>p').removeClass('current');
                        $('.choosePage>p').removeClass('ellipsis');
                        //$('.choosePage>p:eq(' + btn - 1 - ellipsis + ')'),btn - 1 - ellpsis 在jquery选择器中需加括号 → (btn - 1 - ellpsis) 否则报错
                        $('.choosePage>p:eq(' + (btn - 1  - ellipsis) + ')').addClass('ellipsis');
                        var t = $('.choosePage>p:eq(' + (btn - 1  - ellipsis) + ')').text();
                        var h = $('.choosePage>p:eq(' + (btn - 1  - ellipsis) + ')').html().replace(t,'');

                        $('.choosePage>p:eq(' + (btn - 1  - ellipsis) + ')').html('...' + h);
                        
                        for(var n = 0;n < num;n++){
                            var text = $('.choosePage>p')[num - 1 - n].innerText;
                            var html = $('.choosePage>p')[num - 1 - n].innerHTML.replace(text,'');
                            //如果省略号移到后面，被点击的页数小于等于5，则会出现前6个按钮为0,1,2,3,4,5的情况
                            if(inner <= 5){
                                $('.choosePage>p')[num - 1 - n].innerHTML = num - n + html;
                                if(num - n == inner){
                                    $('.choosePage>p:eq(' + (num - 1 - n) + ')').addClass('current');
                                }
                            }else{
                                $('.choosePage>p')[num - 1 - n].innerHTML = inner - n + html;
                                if(inner - n == inner){
                                    $('.choosePage>p:eq(' + (num - 1 - n) + ')').addClass('current');
                                }
                            }
                            
                        }
                        
                    }
                    else if(inner >= num && index == num - 1 && $('.choosePage .ellipsis')[0].ind > btn / 2){
                        console.log(2);
                        $('.choosePage>p').removeClass('current');
                        for(var n = 0;n < num;n++){
                            var text = $('.choosePage>p')[n].innerText;
                            var html = $('.choosePage>p')[n].innerHTML.replace(text,'');
                            $('.choosePage>p')[n].innerHTML = Number(text) + 2 + html;
                            if(Number(text) + 2 == inner){
                                $('.choosePage>p:eq(' + n + ')').addClass('current');
                            }
                        }
                    }
                    else if(inner > 2 && index == 0){
                        console.log(5);
                        $('.choosePage>p').removeClass('current');
                        for(var n = 0;n < num;n++){
                            var text = $('.choosePage>p')[n].innerText;
                            var html = $('.choosePage>p')[n].innerHTML.replace(text,'');
                            $('.choosePage>p')[n].innerHTML = Number(text) - 2 + html;
                            if(Number(text) - 2 == inner){
                                $('.choosePage>p:eq(' + n + ')').addClass('current');
                            }
                        }
                    }
                    else if(inner == 2 && index == 0){
                        console.log(6);
                        $('.choosePage>p').removeClass('current');
                        for(var n = 0;n < num;n++){
                            var text = $('.choosePage>p')[n].innerText;
                            var html = $('.choosePage>p')[n].innerHTML.replace(text,'');
                            $('.choosePage>p')[n].innerHTML = Number(text) - 1 + html;
                            if(Number(text) - 1 == inner){
                                $('.choosePage>p:eq(' + n + ')').addClass('current');
                            }
                        }
                    }
                }
                clearInterval(judge);
                judge = null;
            },10);
        }
        function reloadingAppearing(){
            clearInterval(animate);
            var animations = [];
            for(var l = 0;l < $('.ready').length;l++){
                if($('.ready')[l].tagName != 'LI') continue;
                console.log($('.ready')[l].tagName);
                animations.push($('.ready')[l]);
            }
            console.log('reloading');
            appear = setInterval(function(){
                if(!animations.length){
                    clearInterval(animate);
                };
        
                    for(var n = 0;n < animations.length;n++){
                        var ele_top = animations[n].offsetTop;
                        var ele_h = animations[n].offsetHeight;
                        var window_h = window.innerHeight;
                        var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
                    if((/*ele_top > window_h && */
                        //
                        ele_top < window_h + scrollTop)
                        &&
                        (ele_h + ele_top >scrollTop)
                         ||
                         (ele_top < window_h && scrollTop < ele_top)
                         ||
                         (animations[n].className.indexOf('fixed') > 0)){
                            animations[n].className = animations[n].className + ' frozen';
                            animations.splice(n,1);
                            break;
                    } 
                }
            },10);
        }
        function picAnimate(txt){
            var updatePage = Number(txt) - 1;
            $('.contn .box .page').removeClass('current');
           if($('.library .contn').length){
                $('.library .contn .frozen').removeClass('frozen');
            }
           if($('.cases .contn').length){
                exampleStyleChange('.contn .box .page:eq(' + updatePage + ')');
           }
            var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
            picAnimateDelay = setInterval(function(){
               console.log(updatePage);
                if(toTop == null){
                    $('.contn .box').css('margin-left',-updatePage * 100 + '%');
                    $('.contn .box .page:eq(' + updatePage + ')').addClass('current');
                    
                    if($('.library').length){
                        reloadingAppearing(); 
                    }
                    clearInterval(picAnimateDelay);
                    picAnimateDelay = null;
                }
            },10)
        }
        function prevOrNext(className){
            var btn = $('.choosePage>p').length
            var pages = $('.choosePage>p:eq(' + [btn - 1] + ')').text();
            
            if(className.indexOf('prev') >= 0){
                
                if($('.choosePage .current')[0].ind == 0) return false;
                if($('.choosePage .current').text() == pages - 5 && $('.choosePage .ellipsis')[0].ind < btn / 2){
                    backToTop();
                    updateChoose($('.choosePage .current').text() - 1);
                    picAnimate($('.choosePage .current').text() - 1);
                    return false;
                }
                $('.choosePage .current').prev()[0].click();
            }else{
                if($('.choosePage .current')[0].ind == btn - 1) return false;
                if($('.choosePage .current')[0].ind == 5 && $('.choosePage .ellipsis')[0].ind > btn / 2){
                    backToTop();
                    updateChoose(Number($('.choosePage .current').text()) + 1);
                    picAnimate(Number($('.choosePage .current').text()) + 1);
                    return false;
                }
                $('.choosePage .current').next()[0].click();
            }
        }
        $(document).ready(function(){
            for(var p = 0;p < $('.choosePage>p').length;p++){
                $('.choosePage>p')[p].ind = p;
            }
            $('.choosePage>p').click(function(){
                console.log($(this)[0]);
                if($(this)[0].className.indexOf('ellipsis') >= 0 || $(this)[0].className.indexOf('current') >= 0) return false;
                $('.choosePage>*').removeClass('current');
                $(this).addClass('current');
                updateChoose($(this).text(),$(this)[0].ind);
                picAnimate($(this).text());
                backToTop();
            })
            $('.choosePage>span').click(function(){
                prevOrNext($(this)[0].className);
            })
        })